<div class="categories row">
    <div class="col-md-2">
        <h2><kbd><?php echo __('Actions'); ?></kbd></h2>
        <hr/>
        <ul class="nav nav-stacked" role="navigation">
            <li><?php echo $this->Html->link(__('Edit Category'), array('action' => 'edit', $category['Category']['id'])); ?> </li>
            <li><?php echo $this->Form->postLink(__('Delete Category'), array('action' => 'delete', $category['Category']['id']), null, __('Are you sure you want to delete # %s?', $category['Category']['id'])); ?> </li>
            <li><?php echo $this->Html->link(__('List Categories'), array('action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New Category'), array('action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('List Categories'), array('controller' => 'categories', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('List Transactions'), array('controller' => 'transactions', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New Transaction'), array('controller' => 'transactions', 'action' => 'add')); ?> </li>
        </ul>
    </div>
    <div class="col-md-10">

        <h2><kbd><?php echo __('Category'); ?></kbd></h2>
        <hr/>
        <table class="table table-bordered">
            <tr class="success">
                <td><?php echo __('Id'); ?></td>
                <td><?php echo __('User'); ?></td>
                <td><?php echo __('Name Category'); ?></td>
                <td><?php echo __('Description'); ?></td>
                <td><?php echo __('Parent Category'); ?></td>
                <td><?php echo __('Type'); ?></td>
                <td><?php echo __('Created'); ?></td>
                <td><?php echo __('Updated'); ?></td>
            </tr>
            <tr>
                <td><?php echo h($category['Category']['id']); ?></td>
                <td><?php echo $this->Html->link($category['User']['username'], array('controller' => 'users', 'action' => 'view', $category['User']['id'])); ?></td>
                <td><?php echo h($category['Category']['name']); ?></td>
                <td><?php echo h($category['Category']['description']); ?></td>
                <td><?php echo $this->Html->link($category['ParentCategory']['name'], array('controller' => 'categories', 'action' => 'view', $category['ParentCategory']['id'])); ?></td>
                <td><?php echo $category['Category']['type'] == 1 ? "Earned From" : "Spent On"; ?></td>
                <td><?php echo h($category['Category']['created']); ?></td>
                <td><?php echo h($category['Category']['updated']); ?></td>

            </tr>
        </table>
        <div class="related">
            <h3><?php echo __('Related Categories'); ?></h3>
            <?php if (!empty($category['ChildCategory'])): ?>
                <table class="table table-bordered">
                    <tr class="success">
                        <th><?php echo __('Id'); ?></th>
                        <th><?php echo __('User Id'); ?></th>
                        <th><?php echo __('Name'); ?></th>
                        <th><?php echo __('Description'); ?></th>
                        <th><?php echo __('Parent Id'); ?></th>
                        <th><?php echo __('Type'); ?></th>
                        <th><?php echo __('Created'); ?></th>
                        <th><?php echo __('Updated'); ?></th>
                        <th class="actions"><?php echo __('Actions'); ?></th>
                    </tr>
                    <?php foreach ($category['ChildCategory'] as $childCategory): ?>
                        <tr>
                            <td><?php echo $childCategory['id']; ?></td>
                            <td><?php echo $childCategory['user_id']; ?></td>
                            <td><?php echo $childCategory['name']; ?></td>
                            <td><?php echo $childCategory['description']; ?></td>
                            <td><?php echo $childCategory['parent_id']; ?></td>
                            <td><?php if ($childCategory['type'] == 0)
                                    echo 'Spent on';
                                else echo 'Earn from';
                                ?></td>
                            <td><?php echo $childCategory['created']; ?></td>
                            <td><?php echo $childCategory['updated']; ?></td>
                            <td class="actions">
                                <?php echo $this->Html->link(__('View'), array('controller' => 'categories', 'action' => 'view', $childCategory['id']), array('class' => 'btn-sm btn-info')); ?>
                                <?php echo $this->Html->link(__('Edit'), array('controller' => 'categories', 'action' => 'edit', $childCategory['id']), array('class' => 'btn-sm btn-warning')); ?>
                                <?php echo $this->Form->postLink(__('Delete'), array('controller' => 'categories', 'action' => 'delete', $childCategory['id']), array('class' => 'btn-sm btn-danger'), __('Are you sure you want to delete # %s?', $childCategory['id'])); ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </table>
            <?php endif; ?>

            <div class="actions">
                <ul>
                    <li><?php echo $this->Html->link(__('New Child Category'), array('controller' => 'categories', 'action' => 'add'), array('class' => 'btn-sm btn-success')); ?> </li>
                </ul>
            </div>
        </div>
        <div class="related">
            <h3><?php echo __('Related Transactions'); ?></h3>
            <?php if (!empty($category['Transaction'])): ?>
                <table class="table table-bordered">
                    <tr class="success">
                        <th><?php echo __('Category Id'); ?></th>
                        <th><?php echo __('Wallet Id'); ?></th>
                        <th><?php echo __('Parent Id'); ?></th>
                        <th><?php echo __('Money'); ?></th>
                        <th><?php echo __('Created'); ?></th>
                        <th><?php echo __('Updated'); ?></th>
                        <th><?php echo __('With Who'); ?></th>
                        <th class="actions"><?php echo __('Actions'); ?></th>
                    </tr>
                    <?php foreach ($category['Transaction'] as $transaction): ?>
                        <tr>
                            <td><?php echo $transaction['category_id']; ?></td>
                            <td><?php echo $transaction['wallet_id']; ?></td>
                            <td><?php echo $transaction['parent_id']; ?></td>
                            <td><?php echo number_format($transaction['money']) . ' VND'; ?></td>
                            <td><?php echo $transaction['created']; ?></td>
                            <td><?php echo $transaction['updated']; ?></td>
                            <td><?php echo $transaction['with_who']; ?></td>
                            <td class="actions">
                                <?php echo $this->Html->link(__('View'), array('controller' => 'transactions', 'action' => 'view', $transaction['id']), array('class' => 'btn-sm btn-info')); ?>
                                <?php echo $this->Html->link(__('Edit'), array('controller' => 'transactions', 'action' => 'edit', $transaction['id']), array('class' => 'btn-sm btn-warning')); ?>
                                <?php echo $this->Form->postLink(__('Delete'), array('controller' => 'transactions', 'action' => 'delete', $transaction['id']), array('class' => 'btn-sm btn-danger'), __('Are you sure you want to delete # %s?', $transaction['id'])); ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </table>
            <?php endif; ?>

            <div class="actions">
                <ul>
                    <li><?php echo $this->Html->link(__('New Transaction'), array('controller' => 'transactions', 'action' => 'add'), array('class' => 'btn-sm btn-success')); ?> </li>
                </ul>
            </div>
        </div>
    </div>

